<!doctype html>
<html lang="zh-CN">
<head>

    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">

    <title>mysql总结 | Jeremy Sze的博客</title>
    <meta property="og:title" content="mysql总结 - Jeremy Sze的博客">
    <meta property="og:type" content="article">
        
    <meta property="article:published_time" content='2018-01-11T08:36:54&#43;08:00'>
        
        
    <meta property="article:modified_time" content='2018-01-11T08:36:54&#43;08:00'>
        
    <meta name="Keywords" content="java,博客">
    <meta name="description" content="mysql总结">
        
    <meta name="author" content="Jeremy Sze">
    <meta property="og:url" content="https://laoer123.gitee.io/laoer123/post/mysql%E6%80%BB%E7%BB%93/">
    <link rel="shortcut icon" href="/favicon.ico" type="image/x-icon">

    <link rel="stylesheet" href='/laoer123/css/normalize.css'>
    <link rel="stylesheet" href='/laoer123/css/style.css'>
    <script type="text/javascript" src="//cdnjs.cloudflare.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>

    
    <script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
    <script>
    (adsbygoogle = window.adsbygoogle || []).push({
        google_ad_client: "ca-pub-4031353640611810",
        enable_page_level_ads: true
    });
    </script>
    


    
    
        <link rel="stylesheet" href='/laoer123/css/douban.css'>
    
        <link rel="stylesheet" href='/laoer123/css/other.css'>
    
</head>


<body>
    <header id="header" class="clearfix">
    <div class="container">
        <div class="col-group">
            <div class="site-name ">
                
                    <a id="logo" href="https://laoer123.gitee.io/laoer123">
                        Jeremy Sze的博客
                    </a>
                
                <p class="description">专注于Java、JavaScript、软件开发、web开发、分布式，微服务系统开发</p>
            </div>
            <div>
                <nav id="nav-menu" class="clearfix">
                    <a class="current" href="https://laoer123.gitee.io/laoer123">首页</a>
                    
                    <a  href="https://laoer123.gitee.io/laoer123/about/" title="关于">关于</a>
                    
                </nav>
            </div>
        </div>
    </div>
</header>

    <div id="body">
        <div class="container">
            <div class="col-group">

                <div class="col-8" id="main">
                    
<div class="res-cons">
    <style type="text/css">
    .post-toc {
        position: fixed;
        width: 200px;
        margin-left: -210px;
        padding: 5px 10px;
        font-family: Athelas, STHeiti, Microsoft Yahei, serif;
        font-size: 12px;
        border: 1px solid rgba(0, 0, 0, .07);
        border-radius: 5px;
        background-color: rgba(255, 255, 255, 0.98);
        background-clip: padding-box;
        -webkit-box-shadow: 1px 1px 2px rgba(0, 0, 0, .125);
        box-shadow: 1px 1px 2px rgba(0, 0, 0, .125);
        word-wrap: break-word;
        white-space: nowrap;
        -webkit-box-sizing: border-box;
        box-sizing: border-box;
        z-index: 999;
        cursor: pointer;
        max-height: 70%;
        overflow-y: auto;
        overflow-x: hidden;
    }

    .post-toc .post-toc-title {
        width: 100%;
        margin: 0 auto;
        font-size: 20px;
        font-weight: 400;
        text-transform: uppercase;
        text-align: center;
    }

    .post-toc .post-toc-content {
        font-size: 15px;
    }

    .post-toc .post-toc-content>nav>ul {
        margin: 10px 0;
    }

    .post-toc .post-toc-content ul {
        padding-left: 20px;
        list-style: square;
        margin: 0.5em;
        line-height: 1.8em;
    }

    .post-toc .post-toc-content ul ul {
        padding-left: 15px;
        display: none;
    }

    @media print,
    screen and (max-width:1057px) {
        .post-toc {
            display: none;
        }
    }
</style>
<div class="post-toc" style="position: absolute; top: 188px;">
    <h2 class="post-toc-title">文章目录</h2>
    <div class="post-toc-content">
        <nav id="TableOfContents">
  <ul>
    <li><a href="#mysql概要">mysql概要</a>
      <ul>
        <li><a href="#存储数据方式">存储数据方式</a></li>
      </ul>
    </li>
    <li><a href="#市场上常见的数据库">市场上常见的数据库</a></li>
    <li><a href="#数据库的安装目录">数据库的安装目录</a></li>
    <li><a href="#sql概述">Sql概述</a>
      <ul>
        <li><a href="#sql语句的作用">SQL语句的作用</a></li>
      </ul>
    </li>
    <li><a href="#sql语句的类别">Sql语句的类别</a></li>
    <li><a href="#ddl操作数据库">DDL操作数据库</a></li>
    <li><a href="#mysql数据类型">Mysql数据类型</a></li>
    <li><a href="#ddl语句操作表结构">DDL语句操作表结构</a>
      <ul>
        <li><a href="#创建表">创建表</a></li>
        <li><a href="#复制表结构创建表">复制表结构创建表</a></li>
        <li><a href="#修改表">修改表</a></li>
        <li><a href="#查看表">查看表</a></li>
        <li><a href="#删除表">删除表</a></li>
      </ul>
    </li>
    <li><a href="#dml操作表中数据">DML操作表中数据</a>
      <ul>
        <li><a href="#插入数据">插入数据</a></li>
        <li><a href="#修改表数据">修改表数据</a></li>
        <li><a href="#删除表数据">删除表数据</a></li>
      </ul>
    </li>
    <li><a href="#dql操作数据库">DQL操作数据库</a></li>
    <li><a href="#多表查询">多表查询</a></li>
  </ul>
</nav>
    </div>
</div>
<script type="text/javascript">
    $(document).ready(function () {
        var postToc = $(".post-toc");
        if (postToc.length) {
            var leftPos = $("#main").offset().left;
            if(leftPos<220){
                postToc.css({"width":leftPos-10,"margin-left":(0-leftPos)})
            }

            var t = postToc.offset().top - 20,
                a = {
                    start: {
                        position: "absolute",
                        top: t
                    },
                    process: {
                        position: "fixed",
                        top: 20
                    },
                };
            $(window).scroll(function () {
                var e = $(window).scrollTop();
                e < t ? postToc.css(a.start) : postToc.css(a.process)
            })
        }
    })
</script>
    <article class="post">
        <header>
            <h1 class="post-title">mysql总结</h1>
        </header>
        <date class="post-meta meta-date">
            2018年1月11日
        </date>
        
        <div class="post-meta">
            <span>|</span>
            
            <span class="meta-category"><a href='https://laoer123.gitee.io/categories/%E6%95%B0%E6%8D%AE%E5%BA%93'>数据库</a></span>
            
        </div>
        
        
        <div class="post-meta">
            <span id="busuanzi_container_page_pv">|<span id="busuanzi_value_page_pv"></span><span>
                    阅读</span></span>
        </div>
        
        
        <div class="post-content">
            <h2 id="mysql概要">mysql概要</h2>
<p>数据库:存储数据的仓库。</p>
<h3 id="存储数据方式">存储数据方式</h3>
<p><strong>方式一:可以使用数组、集合存储数据</strong></p>
<p>  优点： 存取的速度比较快， 数据是存储在内存中。</p>
<p>  缺点： 关机或者是断电都会出现数丢失。 而且内存的价格比较贵</p>
<p><strong>方式二:可以将数据存储在文本文件</strong></p>
<p>  优点： 永久性保存数据</p>
<p>  缺点： 查找数据比较麻烦。</p>
<p><strong>方式三:把数据存储到数据库中</strong></p>
<p>  优点： 可以永久性保存数据，查找数据比较方便。</p>
<h2 id="市场上常见的数据库">市场上常见的数据库</h2>
<ol>
<li>MYSQL：开源免费的数据库，小型的数据库.已经被Oracle收购了.MySQL6.x版本也开始收费。</li>
<li>Oracle：收费的大型数据库，Oracle公司的产品。Oracle收购SUN公司，收购MYSQL。</li>
<li>DB2 ：IBM公司的数据库产品,收费的。常应用在银行系统中.</li>
<li>SQLServer：MicroSoft 公司收费的中型的数据库。C#、.net等语言常使用。</li>
<li>SyBase：已经淡出历史舞台。提供了一个非常专业数据建模的工具PowerDesigner。</li>
<li>SQLite: 嵌入式的小型数据库，应用在手机端。</li>
</ol>
<h2 id="数据库的安装目录">数据库的安装目录</h2>
<p><img src="/img/mysql%E7%BB%93%E6%9E%84.png" alt="alt mysql结构"></p>
<h2 id="sql概述">Sql概述</h2>
<p>结构化查询语言(Structured Query Language)简称SQL,SQL语句就是对数据库进行操作的一种语言</p>
<h3 id="sql语句的作用">SQL语句的作用</h3>
<p>Sql语句作用:指挥mysql服务器干活的一些命令。</p>
<h2 id="sql语句的类别">Sql语句的类别</h2>
<ol>
<li>
<p>DDL(Data Definition Language)数据定义语言用来操作数据库表的结构的。 比如： 创建、删除、修改数据库，创建表、修改表结构的。</p>
</li>
<li>
<p>DML(Data Manipulation Language)数据操作语言用来对数据库中表的数据进行增删改。关键字：insert, delete, update等</p>
</li>
<li>
<p>DCL(Data Control Language)数据控制语言(了解)用来定义数据库的访问权限和安全级别，及创建用户。关键字：GRANT， REVOKE等</p>
</li>
<li>
<p>DQL(Data Query Language) 数据查询语言DQL语言并不是属于MYSQL官方的分类，但是对数据库的操作最多就是查询，所以我们的程序员把查询语句的语句称作为DQL语言</p>
</li>
<li>
<p>TCL(Transaction Control Language ) 事务控制语言 用于控制数据库的事务操作，关键字; COMMIT，SAVEPOINT，ROLLBACK等</p>
</li>
</ol>
<h2 id="ddl操作数据库">DDL操作数据库</h2>
<p>创建数据库</p>
<div class="highlight"><div style="background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4">
<table style="border-spacing:0;padding:0;margin:0;border:0;width:auto;overflow:auto;display:block;"><tr><td style="vertical-align:top;padding:0;margin:0;border:0;">
<pre style="background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">1
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">2
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">3
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">4
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">5
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">6
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">7
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">8
</span></code></pre></td>
<td style="vertical-align:top;padding:0;margin:0;border:0;;width:100%">
<pre style="background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-sql" data-lang="sql"><span style="color:#000;font-weight:bold">#</span><span style="color:#a61717;background-color:#e3d2d2">创建一个名字为</span>aa的数据库
<span style="color:#000;font-weight:bold">CREATE</span> <span style="color:#000;font-weight:bold">DATABASE</span> aa;

<span style="color:#000;font-weight:bold">#</span><span style="color:#a61717;background-color:#e3d2d2">判断指定的数据库是否存在，如果不存在的情况下才创建</span>
<span style="color:#000;font-weight:bold">CREATE</span> <span style="color:#000;font-weight:bold">DATABASE</span> <span style="color:#000;font-weight:bold">IF</span>  <span style="color:#000;font-weight:bold">NOT</span> <span style="color:#000;font-weight:bold">EXISTS</span> aa;

<span style="color:#000;font-weight:bold">#</span><span style="color:#a61717;background-color:#e3d2d2">使用指定的码表创建数据库</span>
<span style="color:#000;font-weight:bold">CREATE</span> <span style="color:#000;font-weight:bold">DATABASE</span> cc <span style="color:#0086b3">CHARACTER</span> <span style="color:#000;font-weight:bold">SET</span>  gbk;  
</code></pre></td></tr></table>
</div>
</div><p>查询数据库</p>
<div class="highlight"><div style="background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4">
<table style="border-spacing:0;padding:0;margin:0;border:0;width:auto;overflow:auto;display:block;"><tr><td style="vertical-align:top;padding:0;margin:0;border:0;">
<pre style="background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">1
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">2
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">3
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">4
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">5
</span></code></pre></td>
<td style="vertical-align:top;padding:0;margin:0;border:0;;width:100%">
<pre style="background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-sql" data-lang="sql"><span style="color:#000;font-weight:bold">#</span><span style="color:#a61717;background-color:#e3d2d2">查看所有的数据库</span>
<span style="color:#000;font-weight:bold">SHOW</span> DATABASES;

<span style="color:#000;font-weight:bold">#</span><span style="color:#a61717;background-color:#e3d2d2">查看创建数据库的语句</span>
<span style="color:#000;font-weight:bold">SHOW</span> <span style="color:#000;font-weight:bold">CREATE</span> <span style="color:#000;font-weight:bold">DATABASE</span> aa;
</code></pre></td></tr></table>
</div>
</div><p>修改数据库</p>
<div class="highlight"><div style="background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4">
<table style="border-spacing:0;padding:0;margin:0;border:0;width:auto;overflow:auto;display:block;"><tr><td style="vertical-align:top;padding:0;margin:0;border:0;">
<pre style="background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">1
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">2
</span></code></pre></td>
<td style="vertical-align:top;padding:0;margin:0;border:0;;width:100%">
<pre style="background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-sql" data-lang="sql"><span style="color:#000;font-weight:bold">#</span><span style="color:#a61717;background-color:#e3d2d2">修改数据库码表</span>
<span style="color:#000;font-weight:bold">ALTER</span> <span style="color:#000;font-weight:bold">DATABASE</span>  cc <span style="color:#0086b3">CHARACTER</span>  <span style="color:#000;font-weight:bold">SET</span> utf8;
</code></pre></td></tr></table>
</div>
</div><p>删除数据库</p>
<div class="highlight"><div style="background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4">
<table style="border-spacing:0;padding:0;margin:0;border:0;width:auto;overflow:auto;display:block;"><tr><td style="vertical-align:top;padding:0;margin:0;border:0;">
<pre style="background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">1
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">2
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">3
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">4
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">5
</span></code></pre></td>
<td style="vertical-align:top;padding:0;margin:0;border:0;;width:100%">
<pre style="background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-sql" data-lang="sql"><span style="color:#000;font-weight:bold">#</span><span style="color:#a61717;background-color:#e3d2d2">删除数据库</span>
<span style="color:#000;font-weight:bold">DROP</span>  <span style="color:#000;font-weight:bold">DATABASE</span>   cc;

<span style="color:#000;font-weight:bold">#</span><span style="color:#a61717;background-color:#e3d2d2">删除之前先判断然后在删除</span>
<span style="color:#000;font-weight:bold">DROP</span> <span style="color:#000;font-weight:bold">DATABASE</span> <span style="color:#000;font-weight:bold">IF</span> <span style="color:#000;font-weight:bold">EXISTS</span>  cc;
</code></pre></td></tr></table>
</div>
</div><p>选择数据库</p>
<div class="highlight"><div style="background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4">
<table style="border-spacing:0;padding:0;margin:0;border:0;width:auto;overflow:auto;display:block;"><tr><td style="vertical-align:top;padding:0;margin:0;border:0;">
<pre style="background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">1
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">2
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">3
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">4
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">5
</span></code></pre></td>
<td style="vertical-align:top;padding:0;margin:0;border:0;;width:100%">
<pre style="background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-sql" data-lang="sql"><span style="color:#000;font-weight:bold">#</span> <span style="color:#a61717;background-color:#e3d2d2">查看当前使用的数据库</span>:
<span style="color:#000;font-weight:bold">select</span> <span style="color:#000;font-weight:bold">database</span>();

<span style="color:#000;font-weight:bold">##</span><span style="color:#a61717;background-color:#e3d2d2">选择使用指定的数据库：</span>
use  <span style="color:#a61717;background-color:#e3d2d2">数据库名</span>
</code></pre></td></tr></table>
</div>
</div><h2 id="mysql数据类型">Mysql数据类型</h2>
<p><img src="/img/mysql%E6%95%B0%E6%8D%AE%E7%B1%BB%E5%9E%8B.png" alt="alt mysql数据类型"><br>
<img src="/img/mysql%E6%95%B0%E6%8D%AE%E7%B1%BB%E5%9E%8B1.png" alt="alt mysql数据类型1"></p>
<h2 id="ddl语句操作表结构">DDL语句操作表结构</h2>
<h3 id="创建表">创建表</h3>
<div class="highlight"><div style="background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4">
<table style="border-spacing:0;padding:0;margin:0;border:0;width:auto;overflow:auto;display:block;"><tr><td style="vertical-align:top;padding:0;margin:0;border:0;">
<pre style="background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">1
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">2
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">3
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">4
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">5
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">6
</span></code></pre></td>
<td style="vertical-align:top;padding:0;margin:0;border:0;;width:100%">
<pre style="background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-sql" data-lang="sql"><span style="color:#000;font-weight:bold">CREATE</span> <span style="color:#000;font-weight:bold">TABLE</span> student(
id <span style="color:#0086b3">INT</span>,
NAME <span style="color:#0086b3">VARCHAR</span>(<span style="color:#099">20</span>),
age <span style="color:#0086b3">INT</span>,
sex <span style="color:#0086b3">INT</span>
);
</code></pre></td></tr></table>
</div>
</div><h3 id="复制表结构创建表">复制表结构创建表</h3>
<div class="highlight"><div style="background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4">
<table style="border-spacing:0;padding:0;margin:0;border:0;width:auto;overflow:auto;display:block;"><tr><td style="vertical-align:top;padding:0;margin:0;border:0;">
<pre style="background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">1
</span></code></pre></td>
<td style="vertical-align:top;padding:0;margin:0;border:0;;width:100%">
<pre style="background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-sql" data-lang="sql"><span style="color:#000;font-weight:bold">CREATE</span> <span style="color:#000;font-weight:bold">TABLE</span> BB <span style="color:#000;font-weight:bold">LIKE</span> STUDENT
</code></pre></td></tr></table>
</div>
</div><h3 id="修改表">修改表</h3>
<div class="highlight"><div style="background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4">
<table style="border-spacing:0;padding:0;margin:0;border:0;width:auto;overflow:auto;display:block;"><tr><td style="vertical-align:top;padding:0;margin:0;border:0;">
<pre style="background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"> 1
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"> 2
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"> 3
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"> 4
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"> 5
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"> 6
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"> 7
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"> 8
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"> 9
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">10
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">11
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">12
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">13
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">14
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">15
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">16
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">17
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">18
</span></code></pre></td>
<td style="vertical-align:top;padding:0;margin:0;border:0;;width:100%">
<pre style="background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-sql" data-lang="sql"><span style="color:#000;font-weight:bold">#</span><span style="color:#a61717;background-color:#e3d2d2">增加一个字段</span>
<span style="color:#000;font-weight:bold">ALTER</span> <span style="color:#000;font-weight:bold">TABLE</span> student <span style="color:#000;font-weight:bold">ADD</span> sex <span style="color:#0086b3">CHAR</span>(<span style="color:#099">1</span>);

<span style="color:#000;font-weight:bold">#</span><span style="color:#a61717;background-color:#e3d2d2">修改类型</span>
<span style="color:#000;font-weight:bold">ALTER</span> <span style="color:#000;font-weight:bold">TABLE</span> student <span style="color:#000;font-weight:bold">MODIFY</span> sex <span style="color:#0086b3">VARCHAR</span>(<span style="color:#099">2</span>);


<span style="color:#000;font-weight:bold">#</span><span style="color:#a61717;background-color:#e3d2d2">改变列名</span>
<span style="color:#000;font-weight:bold">ALTER</span> <span style="color:#000;font-weight:bold">TABLE</span> student CHANGE sex gender <span style="color:#0086b3">CHAR</span>(<span style="color:#099">2</span>);

<span style="color:#000;font-weight:bold">#</span><span style="color:#a61717;background-color:#e3d2d2">删除列</span>
<span style="color:#000;font-weight:bold">ALTER</span> <span style="color:#000;font-weight:bold">TABLE</span> student <span style="color:#000;font-weight:bold">DROP</span> gender;

<span style="color:#000;font-weight:bold">#</span><span style="color:#a61717;background-color:#e3d2d2">修改表名</span>
<span style="color:#000;font-weight:bold">ALTER</span> <span style="color:#000;font-weight:bold">TABLE</span> student  <span style="color:#000;font-weight:bold">RENAME</span> <span style="color:#000;font-weight:bold">TO</span> person;

<span style="color:#000;font-weight:bold">RENAME</span> <span style="color:#000;font-weight:bold">TABLE</span> person <span style="color:#000;font-weight:bold">TO</span>  student;

</code></pre></td></tr></table>
</div>
</div><h3 id="查看表">查看表</h3>
<div class="highlight"><div style="background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4">
<table style="border-spacing:0;padding:0;margin:0;border:0;width:auto;overflow:auto;display:block;"><tr><td style="vertical-align:top;padding:0;margin:0;border:0;">
<pre style="background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">1
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">2
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">3
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">4
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">5
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">6
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">7
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">8
</span></code></pre></td>
<td style="vertical-align:top;padding:0;margin:0;border:0;;width:100%">
<pre style="background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-sql" data-lang="sql"><span style="color:#000;font-weight:bold">#</span><span style="color:#a61717;background-color:#e3d2d2">查看所有的表</span>
<span style="color:#000;font-weight:bold">SHOW</span> TABLES;

<span style="color:#000;font-weight:bold">#</span><span style="color:#a61717;background-color:#e3d2d2">查看创建表的</span>sql语句
<span style="color:#000;font-weight:bold">SHOW</span> <span style="color:#000;font-weight:bold">CREATE</span> <span style="color:#000;font-weight:bold">TABLE</span> student;

<span style="color:#000;font-weight:bold">#</span><span style="color:#a61717;background-color:#e3d2d2">查看表结构</span>
<span style="color:#000;font-weight:bold">DESC</span> student;
</code></pre></td></tr></table>
</div>
</div><h3 id="删除表">删除表</h3>
<div class="highlight"><div style="background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4">
<table style="border-spacing:0;padding:0;margin:0;border:0;width:auto;overflow:auto;display:block;"><tr><td style="vertical-align:top;padding:0;margin:0;border:0;">
<pre style="background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">1
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">2
</span></code></pre></td>
<td style="vertical-align:top;padding:0;margin:0;border:0;;width:100%">
<pre style="background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-sql" data-lang="sql"><span style="color:#000;font-weight:bold">#</span><span style="color:#a61717;background-color:#e3d2d2">删除表</span>
<span style="color:#000;font-weight:bold">DROP</span> <span style="color:#000;font-weight:bold">TABLE</span>  <span style="color:#000;font-weight:bold">if</span> <span style="color:#000;font-weight:bold">exists</span> student;
</code></pre></td></tr></table>
</div>
</div><h2 id="dml操作表中数据">DML操作表中数据</h2>
<h3 id="插入数据">插入数据</h3>
<div class="highlight"><div style="background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4">
<table style="border-spacing:0;padding:0;margin:0;border:0;width:auto;overflow:auto;display:block;"><tr><td style="vertical-align:top;padding:0;margin:0;border:0;">
<pre style="background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"> 1
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"> 2
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"> 3
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"> 4
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"> 5
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"> 6
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"> 7
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"> 8
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"> 9
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">10
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">11
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">12
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">13
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">14
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">15
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">16
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">17
</span></code></pre></td>
<td style="vertical-align:top;padding:0;margin:0;border:0;;width:100%">
<pre style="background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-sql" data-lang="sql"><span style="color:#000;font-weight:bold">#</span> <span style="color:#a61717;background-color:#e3d2d2">指定指定名插入数据：</span> 
<span style="color:#000;font-weight:bold">INSERT</span> <span style="color:#000;font-weight:bold">INTO</span> <span style="color:#a61717;background-color:#e3d2d2">表名</span> (<span style="color:#a61717;background-color:#e3d2d2">字段名</span><span style="color:#099">1</span>, <span style="color:#a61717;background-color:#e3d2d2">字段名</span><span style="color:#099">2</span>, <span style="color:#a61717;background-color:#e3d2d2">字段名</span><span style="color:#099">3</span><span style="color:#a61717;background-color:#e3d2d2">…</span>) <span style="color:#000;font-weight:bold">VALUES</span> (<span style="color:#a61717;background-color:#e3d2d2">值</span><span style="color:#099">1</span>, <span style="color:#a61717;background-color:#e3d2d2">值</span><span style="color:#099">2</span>, <span style="color:#a61717;background-color:#e3d2d2">值</span><span style="color:#099">3</span>);

<span style="color:#000;font-weight:bold">#</span> <span style="color:#a61717;background-color:#e3d2d2">不指定字段名插入，但是要求必须要插入所有的字符值。</span>

<span style="color:#000;font-weight:bold">INSERT</span> <span style="color:#000;font-weight:bold">INTO</span> <span style="color:#a61717;background-color:#e3d2d2">表名</span> <span style="color:#000;font-weight:bold">VALUES</span> (<span style="color:#a61717;background-color:#e3d2d2">值</span><span style="color:#099">1</span>, <span style="color:#a61717;background-color:#e3d2d2">值</span><span style="color:#099">2</span>, <span style="color:#a61717;background-color:#e3d2d2">值</span><span style="color:#099">3</span><span style="color:#a61717;background-color:#e3d2d2">…</span>);


<span style="color:#000;font-weight:bold">#</span> <span style="color:#a61717;background-color:#e3d2d2">指定字段名插入数据</span>
<span style="color:#000;font-weight:bold">INSERT</span> <span style="color:#000;font-weight:bold">INTO</span> person(id,NAME,salary) <span style="color:#000;font-weight:bold">VALUES</span>(<span style="color:#099">1</span>,<span style="color:#d14">&#34;hb&#34;</span>,<span style="color:#099">999</span>.<span style="color:#099">99</span>); 

<span style="color:#000;font-weight:bold">#</span><span style="color:#a61717;background-color:#e3d2d2">不指定字段名插入数据</span>
<span style="color:#000;font-weight:bold">INSERT</span> <span style="color:#000;font-weight:bold">INTO</span> person  <span style="color:#000;font-weight:bold">VALUES</span>(<span style="color:#099">2</span>,<span style="color:#d14">&#39;hq&#39;</span>,<span style="color:#099">800</span>,<span style="color:#d14">&#39;1999-12-12 12:12:12&#39;</span>);


<span style="color:#000;font-weight:bold">#</span><span style="color:#a61717;background-color:#e3d2d2">蠕虫复制</span>
<span style="color:#000;font-weight:bold">INSERT</span> <span style="color:#000;font-weight:bold">INTO</span> student <span style="color:#000;font-weight:bold">SELECT</span> <span style="color:#000;font-weight:bold">*</span> <span style="color:#000;font-weight:bold">FROM</span> person;
</code></pre></td></tr></table>
</div>
</div><h3 id="修改表数据">修改表数据</h3>
<div class="highlight"><div style="background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4">
<table style="border-spacing:0;padding:0;margin:0;border:0;width:auto;overflow:auto;display:block;"><tr><td style="vertical-align:top;padding:0;margin:0;border:0;">
<pre style="background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">1
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">2
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">3
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">4
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">5
</span></code></pre></td>
<td style="vertical-align:top;padding:0;margin:0;border:0;;width:100%">
<pre style="background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-sql" data-lang="sql"><span style="color:#000;font-weight:bold">#</span><span style="color:#a61717;background-color:#e3d2d2">修改</span>name为 <span style="color:#998;font-style:italic">--杨诚--
</span><span style="color:#998;font-style:italic"></span><span style="color:#000;font-weight:bold">UPDATE</span> person  <span style="color:#000;font-weight:bold">SET</span> NAME <span style="color:#000;font-weight:bold">=</span> <span style="color:#d14">&#39;杨诚&#39;</span> <span style="color:#000;font-weight:bold">WHERE</span> id <span style="color:#000;font-weight:bold">=</span> <span style="color:#099">3</span>;

<span style="color:#000;font-weight:bold">#</span><span style="color:#a61717;background-color:#e3d2d2">修改多个字段：</span>
<span style="color:#000;font-weight:bold">UPDATE</span> person  <span style="color:#000;font-weight:bold">SET</span> NAME <span style="color:#000;font-weight:bold">=</span><span style="color:#d14">&#39;羊城&#39;</span>,salary<span style="color:#000;font-weight:bold">=</span><span style="color:#099">100</span> <span style="color:#000;font-weight:bold">WHERE</span> id <span style="color:#000;font-weight:bold">=</span> <span style="color:#099">3</span>;
</code></pre></td></tr></table>
</div>
</div><h3 id="删除表数据">删除表数据</h3>
<div class="highlight"><div style="background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4">
<table style="border-spacing:0;padding:0;margin:0;border:0;width:auto;overflow:auto;display:block;"><tr><td style="vertical-align:top;padding:0;margin:0;border:0;">
<pre style="background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">1
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">2
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">3
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">4
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">5
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">6
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">7
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">8
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">9
</span></code></pre></td>
<td style="vertical-align:top;padding:0;margin:0;border:0;;width:100%">
<pre style="background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-sql" data-lang="sql"><span style="color:#000;font-weight:bold">#</span><span style="color:#a61717;background-color:#e3d2d2">删除所有的数据（一条条删除）</span>
<span style="color:#000;font-weight:bold">DELETE</span>  <span style="color:#000;font-weight:bold">FROM</span>  person;

<span style="color:#000;font-weight:bold">#</span><span style="color:#a61717;background-color:#e3d2d2">催表结构，然后销毁数据，再重建表结构，效率高</span>
<span style="color:#000;font-weight:bold">TRUNCATE</span> person;


<span style="color:#000;font-weight:bold">#</span><span style="color:#a61717;background-color:#e3d2d2">删除指定的数据</span>
<span style="color:#000;font-weight:bold">DELETE</span> <span style="color:#000;font-weight:bold">FROM</span> person  <span style="color:#000;font-weight:bold">WHERE</span> id <span style="color:#000;font-weight:bold">=</span><span style="color:#099">3</span>;
</code></pre></td></tr></table>
</div>
</div><h2 id="dql操作数据库">DQL操作数据库</h2>
<div class="highlight"><div style="background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4">
<table style="border-spacing:0;padding:0;margin:0;border:0;width:auto;overflow:auto;display:block;"><tr><td style="vertical-align:top;padding:0;margin:0;border:0;">
<pre style="background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">  1
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">  2
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">  3
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">  4
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">  5
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">  6
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">  7
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">  8
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">  9
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"> 10
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"> 11
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"> 12
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"> 13
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"> 14
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"> 15
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"> 16
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"> 17
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"> 18
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"> 19
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"> 20
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"> 21
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"> 22
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"> 23
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"> 24
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"> 25
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"> 26
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"> 27
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"> 28
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"> 29
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"> 30
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"> 31
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"> 32
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"> 33
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"> 34
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"> 35
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"> 36
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"> 37
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"> 38
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"> 39
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"> 40
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"> 41
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"> 42
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"> 43
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"> 44
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"> 45
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"> 46
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"> 47
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"> 48
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"> 49
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"> 50
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"> 51
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"> 52
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"> 53
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"> 54
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"> 55
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"> 56
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"> 57
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"> 58
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"> 59
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"> 60
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"> 61
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"> 62
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"> 63
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"> 64
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"> 65
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"> 66
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"> 67
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"> 68
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"> 69
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"> 70
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"> 71
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"> 72
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"> 73
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"> 74
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"> 75
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"> 76
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"> 77
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"> 78
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"> 79
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"> 80
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"> 81
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"> 82
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"> 83
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"> 84
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"> 85
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"> 86
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"> 87
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"> 88
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"> 89
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"> 90
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"> 91
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"> 92
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"> 93
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"> 94
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"> 95
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"> 96
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"> 97
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"> 98
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"> 99
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">100
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">101
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">102
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">103
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">104
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">105
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">106
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">107
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">108
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">109
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">110
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">111
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">112
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">113
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">114
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">115
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">116
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">117
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">118
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">119
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">120
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">121
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">122
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">123
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">124
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">125
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">126
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">127
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">128
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">129
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">130
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">131
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">132
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">133
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">134
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">135
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">136
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">137
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">138
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">139
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">140
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">141
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">142
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">143
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">144
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">145
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">146
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">147
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">148
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">149
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">150
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">151
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">152
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">153
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">154
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">155
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">156
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">157
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">158
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">159
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">160
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">161
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">162
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">163
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">164
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">165
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">166
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">167
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">168
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">169
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">170
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">171
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">172
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">173
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">174
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">175
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">176
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">177
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">178
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">179
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">180
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">181
</span></code></pre></td>
<td style="vertical-align:top;padding:0;margin:0;border:0;;width:100%">
<pre style="background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-sql" data-lang="sql"><span style="color:#000;font-weight:bold">#</span><span style="color:#099">1</span>.<span style="color:#a61717;background-color:#e3d2d2">查询</span>student所有列
<span style="color:#000;font-weight:bold">SELECT</span> <span style="color:#000;font-weight:bold">*</span>  <span style="color:#000;font-weight:bold">FROM</span> student;

<span style="color:#000;font-weight:bold">#</span><span style="color:#099">2</span>.<span style="color:#a61717;background-color:#e3d2d2">查询指定的列</span>
<span style="color:#000;font-weight:bold">SELECT</span> NAME,age,sex <span style="color:#000;font-weight:bold">FROM</span> student;


<span style="color:#000;font-weight:bold">#</span><span style="color:#099">3</span>.<span style="color:#a61717;background-color:#e3d2d2">别名查询</span>
<span style="color:#000;font-weight:bold">SELECT</span> NAME <span style="color:#000;font-weight:bold">AS</span> <span style="color:#a61717;background-color:#e3d2d2">姓名</span>,age <span style="color:#000;font-weight:bold">AS</span> <span style="color:#a61717;background-color:#e3d2d2">年龄</span>,sex <span style="color:#000;font-weight:bold">AS</span> <span style="color:#a61717;background-color:#e3d2d2">性别</span> <span style="color:#000;font-weight:bold">FROM</span> student;

<span style="color:#000;font-weight:bold">SELECT</span> NAME  <span style="color:#a61717;background-color:#e3d2d2">姓名</span>,age  <span style="color:#a61717;background-color:#e3d2d2">年龄</span>,sex  <span style="color:#a61717;background-color:#e3d2d2">性别</span>,math <span style="color:#a61717;background-color:#e3d2d2">数学</span> <span style="color:#000;font-weight:bold">FROM</span> student;


<span style="color:#000;font-weight:bold">#</span><span style="color:#099">4</span>.<span style="color:#a61717;background-color:#e3d2d2">清除重复值</span>(<span style="color:#a61717;background-color:#e3d2d2">如果年龄与姓名都一样，那么只显示一条数据</span>)  <span style="color:#000;font-weight:bold">distinct</span>
<span style="color:#000;font-weight:bold">SELECT</span> <span style="color:#000;font-weight:bold">DISTINCT</span> NAME <span style="color:#000;font-weight:bold">FROM</span> student;

<span style="color:#000;font-weight:bold">#</span><span style="color:#099">5</span>.<span style="color:#a61717;background-color:#e3d2d2">查询参与运算（查询出</span>mathenglish的成绩总和<span style="color:#a61717;background-color:#e3d2d2">）</span> <span style="color:#a61717;background-color:#e3d2d2">查询每一位学员的成绩总和</span>
<span style="color:#000;font-weight:bold">SELECT</span> NAME <span style="color:#a61717;background-color:#e3d2d2">姓名</span>, math<span style="color:#000;font-weight:bold">+</span><span style="color:#099">10</span> <span style="color:#a61717;background-color:#e3d2d2">数学</span> ,english <span style="color:#a61717;background-color:#e3d2d2">英语</span>  ,(math<span style="color:#000;font-weight:bold">+</span>english) <span style="color:#a61717;background-color:#e3d2d2">总和</span>  <span style="color:#000;font-weight:bold">FROM</span> student;


<span style="color:#000;font-weight:bold">#</span><span style="color:#099">1</span>.<span style="color:#a61717;background-color:#e3d2d2">查询</span>student所有列

<span style="color:#000;font-weight:bold">SELECT</span> <span style="color:#000;font-weight:bold">*</span> <span style="color:#000;font-weight:bold">FROM</span> student

<span style="color:#000;font-weight:bold">#</span><span style="color:#099">2</span>.<span style="color:#a61717;background-color:#e3d2d2">查询指定的列</span>

<span style="color:#000;font-weight:bold">SELECT</span> NAME <span style="color:#000;font-weight:bold">FROM</span> student 

<span style="color:#000;font-weight:bold">#</span><span style="color:#099">3</span>.<span style="color:#a61717;background-color:#e3d2d2">别名查询</span>
<span style="color:#000;font-weight:bold">SELECT</span> NAME <span style="color:#d14">&#39;学生&#39;</span>,age <span style="color:#d14">&#39;年龄&#39;</span>,sex <span style="color:#d14">&#39;性别&#39;</span> <span style="color:#000;font-weight:bold">FROM</span> student


<span style="color:#000;font-weight:bold">#</span><span style="color:#099">4</span>.<span style="color:#a61717;background-color:#e3d2d2">清除重复值</span>(<span style="color:#a61717;background-color:#e3d2d2">如果年龄与姓名都一样，那么只显示一条数据</span>)  <span style="color:#000;font-weight:bold">distinct</span>
<span style="color:#000;font-weight:bold">SELECT</span> <span style="color:#000;font-weight:bold">DISTINCT</span> NAME <span style="color:#000;font-weight:bold">FROM</span> student

<span style="color:#000;font-weight:bold">#</span><span style="color:#099">5</span>.<span style="color:#a61717;background-color:#e3d2d2">查询参与运算（查询出</span>mathenglish的成绩总和<span style="color:#a61717;background-color:#e3d2d2">）</span> <span style="color:#a61717;background-color:#e3d2d2">查询每一位学员的成绩总和</span>

<span style="color:#000;font-weight:bold">SELECT</span> NAME <span style="color:#d14">&#39;学生&#39;</span>,math <span style="color:#d14">&#39;数学&#39;</span>,english <span style="color:#d14">&#39;英语&#39;</span>,(math<span style="color:#000;font-weight:bold">+</span>english)<span style="color:#a61717;background-color:#e3d2d2">总成绩</span> <span style="color:#000;font-weight:bold">FROM</span> student

<span style="color:#000;font-weight:bold">#==================================================</span><span style="color:#a61717;background-color:#e3d2d2">条件查询</span><span style="color:#000;font-weight:bold">============================================</span>


<span style="color:#000;font-weight:bold">#</span><span style="color:#099">1</span>.<span style="color:#a61717;background-color:#e3d2d2">查询</span>math分数大于80分的学生
   <span style="color:#000;font-weight:bold">SELECT</span> NAME <span style="color:#d14">&#39;学生&#39;</span> ,math <span style="color:#d14">&#39;数学&#39;</span><span style="color:#000;font-weight:bold">FROM</span> student <span style="color:#000;font-weight:bold">WHERE</span> math <span style="color:#000;font-weight:bold">&gt;</span><span style="color:#099">80</span>	
   
   
<span style="color:#000;font-weight:bold">#</span><span style="color:#099">2</span>.<span style="color:#a61717;background-color:#e3d2d2">查询</span>english分数小于或等于80分的学生
<span style="color:#000;font-weight:bold">SELECT</span> NAME <span style="color:#d14">&#39;学生&#39;</span>,English <span style="color:#d14">&#39;英语&#39;</span> <span style="color:#000;font-weight:bold">FROM</span> student <span style="color:#000;font-weight:bold">WHERE</span> english <span style="color:#000;font-weight:bold">&lt;</span><span style="color:#099">80</span> <span style="color:#000;font-weight:bold">OR</span> english<span style="color:#000;font-weight:bold">=</span><span style="color:#099">80</span>;
	
<span style="color:#000;font-weight:bold">#</span><span style="color:#099">3</span>.<span style="color:#a61717;background-color:#e3d2d2">查询</span>age等于20岁的学生
	
  <span style="color:#000;font-weight:bold">SELECT</span> NAME <span style="color:#d14">&#39;学生&#39;</span> ,age <span style="color:#d14">&#39;年龄&#39;</span><span style="color:#000;font-weight:bold">FROM</span> student <span style="color:#000;font-weight:bold">WHERE</span> age <span style="color:#000;font-weight:bold">=</span><span style="color:#099">20</span>;

<span style="color:#000;font-weight:bold">#</span><span style="color:#099">4</span>.<span style="color:#a61717;background-color:#e3d2d2">查询</span>age不等于20岁的学生
    
   <span style="color:#000;font-weight:bold">SELECT</span> NAME <span style="color:#d14">&#39;学生&#39;</span> ,age <span style="color:#d14">&#39;年龄&#39;</span><span style="color:#000;font-weight:bold">FROM</span> student <span style="color:#000;font-weight:bold">WHERE</span> age <span style="color:#000;font-weight:bold">!=</span><span style="color:#099">20</span>;



<span style="color:#000;font-weight:bold">#</span><span style="color:#a61717;background-color:#e3d2d2">逻辑运算符</span>

<span style="color:#000;font-weight:bold">#</span><span style="color:#099">1</span>.<span style="color:#a61717;background-color:#e3d2d2">查询</span>age大于35且性别为男的学生(<span style="color:#a61717;background-color:#e3d2d2">两个条件同时满足</span>)
 <span style="color:#000;font-weight:bold">SELECT</span> NAME ,age ,sex <span style="color:#000;font-weight:bold">FROM</span> student <span style="color:#000;font-weight:bold">WHERE</span> age <span style="color:#000;font-weight:bold">&lt;</span><span style="color:#099">35</span> <span style="color:#000;font-weight:bold">AND</span> sex <span style="color:#000;font-weight:bold">=</span><span style="color:#d14">&#39;男&#39;</span>;
      
      
<span style="color:#000;font-weight:bold">#</span><span style="color:#099">2</span>.<span style="color:#a61717;background-color:#e3d2d2">查询</span>age大于35或性别为男的学生(<span style="color:#a61717;background-color:#e3d2d2">两个条件其中一个满足</span>)
 <span style="color:#000;font-weight:bold">SELECT</span> NAME ,age ,sex <span style="color:#000;font-weight:bold">FROM</span> student <span style="color:#000;font-weight:bold">WHERE</span> age <span style="color:#000;font-weight:bold">&lt;</span><span style="color:#099">35</span> <span style="color:#000;font-weight:bold">OR</span> sex <span style="color:#000;font-weight:bold">=</span><span style="color:#d14">&#39;男&#39;</span>;
	
      

<span style="color:#000;font-weight:bold">#</span><span style="color:#099">3</span>.<span style="color:#a61717;background-color:#e3d2d2">查询</span>id是1或3或5的学生(<span style="color:#000;font-weight:bold">or</span>  <span style="color:#000;font-weight:bold">in</span> ), <span style="color:#a61717;background-color:#e3d2d2">表示一个范围可以使用</span>in语句
	
      <span style="color:#000;font-weight:bold">SELECT</span> <span style="color:#000;font-weight:bold">*</span> <span style="color:#000;font-weight:bold">FROM</span> student <span style="color:#000;font-weight:bold">WHERE</span> id<span style="color:#000;font-weight:bold">=</span><span style="color:#099">1</span> <span style="color:#000;font-weight:bold">OR</span> id<span style="color:#000;font-weight:bold">=</span><span style="color:#099">3</span> <span style="color:#000;font-weight:bold">OR</span> id<span style="color:#000;font-weight:bold">=</span><span style="color:#099">5</span>;
      
      <span style="color:#000;font-weight:bold">SELECT</span> <span style="color:#000;font-weight:bold">*</span> <span style="color:#000;font-weight:bold">FROM</span> student <span style="color:#000;font-weight:bold">WHERE</span> id <span style="color:#000;font-weight:bold">IN</span>(<span style="color:#099">1</span>,<span style="color:#099">3</span>,<span style="color:#099">5</span>);
   
<span style="color:#000;font-weight:bold">#</span> <span style="color:#099">5</span>.<span style="color:#a61717;background-color:#e3d2d2">查询</span>id不是1或3或5的学生<span style="color:#a61717;background-color:#e3d2d2">，</span> <span style="color:#a61717;background-color:#e3d2d2">不在范围之内使用</span><span style="color:#000;font-weight:bold">not</span> <span style="color:#000;font-weight:bold">IN</span>
<span style="color:#000;font-weight:bold">SELECT</span> <span style="color:#000;font-weight:bold">*</span> <span style="color:#000;font-weight:bold">FROM</span> student <span style="color:#000;font-weight:bold">WHERE</span>  id <span style="color:#000;font-weight:bold">NOT</span> <span style="color:#000;font-weight:bold">IN</span>(<span style="color:#099">1</span>,<span style="color:#099">3</span>,<span style="color:#099">5</span>);
   

<span style="color:#000;font-weight:bold">##</span><span style="color:#099">1</span>.<span style="color:#099">2</span>.<span style="color:#099">3</span><span style="color:#a61717;background-color:#e3d2d2">范围</span>

<span style="color:#000;font-weight:bold">##</span><span style="color:#099">1</span>.<span style="color:#a61717;background-color:#e3d2d2">查询</span>english成绩大于等于75<span style="color:#a61717;background-color:#e3d2d2">，且小于等于</span><span style="color:#099">90</span><span style="color:#a61717;background-color:#e3d2d2">的学生</span> <span style="color:#a61717;background-color:#e3d2d2">，</span> <span style="color:#a61717;background-color:#e3d2d2">可以使用</span> <span style="color:#000;font-weight:bold">BETWEEN</span>  <span style="color:#a61717;background-color:#e3d2d2">语句</span>

<span style="color:#000;font-weight:bold">SELECT</span> NAME ,english <span style="color:#000;font-weight:bold">FROM</span> <span style="color:#000;font-weight:bold">`</span>student<span style="color:#000;font-weight:bold">`</span> <span style="color:#000;font-weight:bold">WHERE</span> english  <span style="color:#000;font-weight:bold">BETWEEN</span> <span style="color:#099">75</span> <span style="color:#000;font-weight:bold">AND</span> <span style="color:#099">90</span>;





<span style="color:#000;font-weight:bold">#</span><span style="color:#a61717;background-color:#e3d2d2">模糊查询</span>  <span style="color:#a61717;background-color:#e3d2d2">模糊查询使用到的关键字</span><span style="color:#000;font-weight:bold">like</span> <span style="color:#a61717;background-color:#e3d2d2">。</span>   <span style="color:#a61717;background-color:#e3d2d2">模糊查询常用的两个字符：</span><span style="color:#000;font-weight:bold">%</span> <span style="color:#a61717;background-color:#e3d2d2">表示匹配任何字符而且不限个数</span>      _ <span style="color:#a61717;background-color:#e3d2d2">表示任何字符，但是只能匹配一个字符。</span>

<span style="color:#000;font-weight:bold">#</span><span style="color:#099">1</span>.<span style="color:#a61717;background-color:#e3d2d2">查询姓张的学生</span>
<span style="color:#000;font-weight:bold">SELECT</span> <span style="color:#000;font-weight:bold">*</span> <span style="color:#000;font-weight:bold">FROM</span> student <span style="color:#000;font-weight:bold">WHERE</span> NAME  <span style="color:#000;font-weight:bold">LIKE</span> <span style="color:#d14">&#39;张%&#39;</span>;

<span style="color:#000;font-weight:bold">#</span><span style="color:#099">2</span>.<span style="color:#a61717;background-color:#e3d2d2">查询姓名中包含</span><span style="color:#d14">&#39;德&#39;</span><span style="color:#a61717;background-color:#e3d2d2">字的学生</span>

<span style="color:#000;font-weight:bold">SELECT</span> <span style="color:#000;font-weight:bold">*</span> <span style="color:#000;font-weight:bold">FROM</span> <span style="color:#000;font-weight:bold">`</span>student3<span style="color:#000;font-weight:bold">`</span> <span style="color:#000;font-weight:bold">WHERE</span> NAME <span style="color:#000;font-weight:bold">LIKE</span> <span style="color:#d14">&#39;%德%&#39;</span>
<span style="color:#000;font-weight:bold">#</span><span style="color:#099">3</span>.<span style="color:#a61717;background-color:#e3d2d2">查询姓马，且姓名有德个字的学生</span>
<span style="color:#000;font-weight:bold">SELECT</span> <span style="color:#000;font-weight:bold">*</span> <span style="color:#000;font-weight:bold">FROM</span> student3 <span style="color:#000;font-weight:bold">WHERE</span>  NAME <span style="color:#000;font-weight:bold">LIKE</span> <span style="color:#d14">&#39;马%&#39;</span> <span style="color:#000;font-weight:bold">AND</span>  NAME <span style="color:#000;font-weight:bold">LIKE</span> <span style="color:#d14">&#39;%德%&#39;</span>

<span style="color:#000;font-weight:bold">#===============================================</span><span style="color:#a61717;background-color:#e3d2d2">排序</span><span style="color:#000;font-weight:bold">==============================</span>

<span style="color:#000;font-weight:bold">#</span><span style="color:#a61717;background-color:#e3d2d2">排序需要使用到的关键字</span>   <span style="color:#000;font-weight:bold">order</span> <span style="color:#000;font-weight:bold">by</span>  <span style="color:#a61717;background-color:#e3d2d2">字段名</span>  <span style="color:#000;font-weight:bold">desc</span> <span style="color:#000;font-weight:bold">|</span> <span style="color:#000;font-weight:bold">asc</span> <span style="color:#a61717;background-color:#e3d2d2">。</span> 
<span style="color:#000;font-weight:bold">SELECT</span> <span style="color:#000;font-weight:bold">*</span> <span style="color:#000;font-weight:bold">FROM</span> student3   <span style="color:#000;font-weight:bold">ORDER</span> <span style="color:#000;font-weight:bold">BY</span> ID <span style="color:#000;font-weight:bold">DESC</span>

<span style="color:#000;font-weight:bold">#</span>  <span style="color:#000;font-weight:bold">desc</span> <span style="color:#a61717;background-color:#e3d2d2">降序</span>  <span style="color:#000;font-weight:bold">asc</span>  <span style="color:#a61717;background-color:#e3d2d2">升序（默认）</span>

<span style="color:#000;font-weight:bold">#</span><span style="color:#099">1</span>.<span style="color:#a61717;background-color:#e3d2d2">查询所有数据</span>,<span style="color:#a61717;background-color:#e3d2d2">使用年龄降序排序</span>

<span style="color:#000;font-weight:bold">SELECT</span> <span style="color:#000;font-weight:bold">*</span> <span style="color:#000;font-weight:bold">FROM</span>  student3 <span style="color:#000;font-weight:bold">ORDER</span> <span style="color:#000;font-weight:bold">BY</span>  age <span style="color:#000;font-weight:bold">DESC</span> 


<span style="color:#000;font-weight:bold">#</span><span style="color:#099">2</span>.<span style="color:#a61717;background-color:#e3d2d2">查询所有数据</span>,<span style="color:#a61717;background-color:#e3d2d2">在年龄降序排序的基础上，如果年龄相同再以数学成绩降序排序</span>(<span style="color:#a61717;background-color:#e3d2d2">组合排序</span>)
<span style="color:#000;font-weight:bold">SELECT</span> <span style="color:#000;font-weight:bold">*</span> <span style="color:#000;font-weight:bold">FROM</span> student3 <span style="color:#000;font-weight:bold">ORDER</span> <span style="color:#000;font-weight:bold">BY</span> age <span style="color:#000;font-weight:bold">DESC</span> , math <span style="color:#000;font-weight:bold">ASC</span> 


<span style="color:#000;font-weight:bold">SELECT</span> <span style="color:#000;font-weight:bold">*</span> <span style="color:#000;font-weight:bold">FROM</span> student3 <span style="color:#000;font-weight:bold">ORDER</span> <span style="color:#000;font-weight:bold">BY</span> math   <span style="color:#000;font-weight:bold">ASC</span>

<span style="color:#000;font-weight:bold">#======================================================</span><span style="color:#a61717;background-color:#e3d2d2">聚合函数</span><span style="color:#000;font-weight:bold">===================================</span>

<span style="color:#000;font-weight:bold">#</span><span style="color:#099">1</span>.<span style="color:#a61717;background-color:#e3d2d2">查询学生总数，</span> <span style="color:#000;font-weight:bold">count</span>() ifnull(<span style="color:#a61717;background-color:#e3d2d2">字段名，默认值</span>)   <span style="color:#a61717;background-color:#e3d2d2">函数</span>, <span style="color:#a61717;background-color:#e3d2d2">本质就是帮你统计查询结果的行数。</span> count函数统计的时候会排除null值在外<span style="color:#a61717;background-color:#e3d2d2">，</span> 
<span style="color:#000;font-weight:bold">SELECT</span> <span style="color:#000;font-weight:bold">COUNT</span>(english)   <span style="color:#a61717;background-color:#e3d2d2">总人数</span> <span style="color:#000;font-weight:bold">FROM</span>  student3;

<span style="color:#000;font-weight:bold">SELECT</span>  <span style="color:#000;font-weight:bold">COUNT</span>(IFNULL(english,<span style="color:#099">0</span>)) <span style="color:#000;font-weight:bold">FROM</span> student3;


<span style="color:#000;font-weight:bold">#</span><span style="color:#099">2</span>.<span style="color:#a61717;background-color:#e3d2d2">查询年龄大于</span><span style="color:#099">40</span><span style="color:#a61717;background-color:#e3d2d2">的总数</span>
<span style="color:#000;font-weight:bold">SELECT</span> <span style="color:#000;font-weight:bold">COUNT</span>(ID) <span style="color:#a61717;background-color:#e3d2d2">总人数</span> <span style="color:#000;font-weight:bold">FROM</span> student3 <span style="color:#000;font-weight:bold">WHERE</span> age<span style="color:#000;font-weight:bold">&gt;</span><span style="color:#099">40</span>
<span style="color:#000;font-weight:bold">#</span><span style="color:#099">3</span>.<span style="color:#a61717;background-color:#e3d2d2">查询数学成绩总分</span>  <span style="color:#000;font-weight:bold">sum</span>()

<span style="color:#000;font-weight:bold">SELECT</span>  <span style="color:#000;font-weight:bold">SUM</span>(math)  <span style="color:#a61717;background-color:#e3d2d2">数学总分</span> <span style="color:#000;font-weight:bold">FROM</span> student3 


<span style="color:#000;font-weight:bold">#</span><span style="color:#099">3</span>.<span style="color:#a61717;background-color:#e3d2d2">查询数学成绩平均分</span>, <span style="color:#000;font-weight:bold">avg</span>()
<span style="color:#000;font-weight:bold">SELECT</span> <span style="color:#000;font-weight:bold">AVG</span>(math) <span style="color:#000;font-weight:bold">FROM</span> student3 


<span style="color:#000;font-weight:bold">#</span><span style="color:#099">4</span>.<span style="color:#a61717;background-color:#e3d2d2">查询数学成绩最高分</span>   <span style="color:#000;font-weight:bold">max</span>
<span style="color:#000;font-weight:bold">SELECT</span> <span style="color:#000;font-weight:bold">MAX</span>(math) <span style="color:#000;font-weight:bold">FROM</span> student3 
<span style="color:#000;font-weight:bold">#</span><span style="color:#099">5</span>.<span style="color:#a61717;background-color:#e3d2d2">查询数学成绩最低分</span>   <span style="color:#000;font-weight:bold">min</span>

<span style="color:#000;font-weight:bold">SELECT</span> <span style="color:#000;font-weight:bold">MIN</span>(math) <span style="color:#000;font-weight:bold">FROM</span> student3

<span style="color:#000;font-weight:bold">#==============================================</span><span style="color:#a61717;background-color:#e3d2d2">分组</span><span style="color:#000;font-weight:bold">==================================</span>

<span style="color:#000;font-weight:bold">#</span> <span style="color:#a61717;background-color:#e3d2d2">分组需要使用的关键字：</span> <span style="color:#000;font-weight:bold">group</span> <span style="color:#000;font-weight:bold">by</span> <span style="color:#a61717;background-color:#e3d2d2">字段名。</span>  <span style="color:#a61717;background-color:#e3d2d2">使用</span>gourp by查询的字段只能是聚合函数或者是分组的字段<span style="color:#a61717;background-color:#e3d2d2">，其他字段一律不准出现。</span>

<span style="color:#000;font-weight:bold">##</span> <span style="color:#099">1</span>.<span style="color:#a61717;background-color:#e3d2d2">查询男女各多少人</span>

<span style="color:#000;font-weight:bold">SELECT</span> sex <span style="color:#000;font-weight:bold">FROM</span> student3  <span style="color:#000;font-weight:bold">GROUP</span> <span style="color:#000;font-weight:bold">BY</span> sex

<span style="color:#000;font-weight:bold">#</span><span style="color:#099">2</span>.<span style="color:#a61717;background-color:#e3d2d2">查询年龄大于</span><span style="color:#099">25</span><span style="color:#a61717;background-color:#e3d2d2">岁的人</span>,<span style="color:#a61717;background-color:#e3d2d2">按性别分组</span>,<span style="color:#a61717;background-color:#e3d2d2">统计每组的人数</span>( <span style="color:#a61717;background-color:#e3d2d2">询年龄大于</span><span style="color:#099">25</span><span style="color:#a61717;background-color:#e3d2d2">岁的人这条件的数据是在分组之前就存在的还是分组之后才存在</span>) 
<span style="color:#000;font-weight:bold">SELECT</span> sex ,<span style="color:#000;font-weight:bold">COUNT</span>(<span style="color:#000;font-weight:bold">*</span>) <span style="color:#a61717;background-color:#e3d2d2">总人数</span> <span style="color:#000;font-weight:bold">FROM</span> student3 <span style="color:#000;font-weight:bold">WHERE</span> age<span style="color:#000;font-weight:bold">&gt;</span><span style="color:#099">25</span> <span style="color:#000;font-weight:bold">GROUP</span> <span style="color:#000;font-weight:bold">BY</span> sex 

<span style="color:#000;font-weight:bold">#</span><span style="color:#099">3</span>.<span style="color:#a61717;background-color:#e3d2d2">查询年龄大于</span><span style="color:#099">25</span><span style="color:#a61717;background-color:#e3d2d2">岁的人</span>,<span style="color:#a61717;background-color:#e3d2d2">按性别分组</span>,<span style="color:#a61717;background-color:#e3d2d2">统计每组的人数</span>,<span style="color:#a61717;background-color:#e3d2d2">并只显示性别人数大于</span><span style="color:#099">2</span><span style="color:#a61717;background-color:#e3d2d2">的数据</span>(<span style="color:#a61717;background-color:#e3d2d2">只显示性别人数大于</span><span style="color:#099">2</span><span style="color:#a61717;background-color:#e3d2d2">的数据</span> <span style="color:#a61717;background-color:#e3d2d2">这个数据是分组之后</span>)
<span style="color:#000;font-weight:bold">SELECT</span> sex ,<span style="color:#000;font-weight:bold">COUNT</span>(<span style="color:#000;font-weight:bold">*</span>) <span style="color:#a61717;background-color:#e3d2d2">总人数</span> <span style="color:#000;font-weight:bold">FROM</span> student3 <span style="color:#000;font-weight:bold">WHERE</span> age<span style="color:#000;font-weight:bold">&gt;</span><span style="color:#099">25</span> <span style="color:#000;font-weight:bold">GROUP</span> <span style="color:#000;font-weight:bold">BY</span> sex <span style="color:#000;font-weight:bold">HAVING</span> <span style="color:#a61717;background-color:#e3d2d2">总人数</span><span style="color:#000;font-weight:bold">&gt;</span><span style="color:#099">2</span>



<span style="color:#000;font-weight:bold">##</span><span style="color:#a61717;background-color:#e3d2d2">相同处：</span> <span style="color:#a61717;background-color:#e3d2d2">后面都是跟着条件的。</span> 

<span style="color:#000;font-weight:bold">##</span> <span style="color:#a61717;background-color:#e3d2d2">不同之处：</span> where是出现在分组之前的条件数据筛选<span style="color:#a61717;background-color:#e3d2d2">，</span> having是出现在分组之后条件数据筛选<span style="color:#a61717;background-color:#e3d2d2">。</span> 

<span style="color:#000;font-weight:bold">##</span>  <span style="color:#a61717;background-color:#e3d2d2">查询每个部门中薪资最高的人员信息</span>
<span style="color:#000;font-weight:bold">select</span> d.Name <span style="color:#000;font-weight:bold">as</span> Department, e.Name <span style="color:#000;font-weight:bold">as</span> Employee, Salary
<span style="color:#000;font-weight:bold">from</span> Employee e <span style="color:#000;font-weight:bold">join</span> Department d <span style="color:#000;font-weight:bold">on</span> e.DepartmentId <span style="color:#000;font-weight:bold">=</span> d.Id
<span style="color:#000;font-weight:bold">where</span> (e.DepartmentId, e.Salary) <span style="color:#000;font-weight:bold">in</span> (
    <span style="color:#000;font-weight:bold">select</span> DepartmentId, <span style="color:#000;font-weight:bold">max</span>(Salary)
    <span style="color:#000;font-weight:bold">from</span> Employee
    <span style="color:#000;font-weight:bold">group</span> <span style="color:#000;font-weight:bold">by</span> DepartmentId
);


<span style="color:#000;font-weight:bold">#==================================</span>limit语句<span style="color:#000;font-weight:bold">================================</span>

<span style="color:#000;font-weight:bold">#</span><span style="color:#099">1</span>.<span style="color:#a61717;background-color:#e3d2d2">查询学生表中数据，从第三条开始显示，显示</span><span style="color:#099">6</span><span style="color:#a61717;background-color:#e3d2d2">条</span>()

<span style="color:#000;font-weight:bold">SELECT</span> <span style="color:#000;font-weight:bold">*</span> <span style="color:#000;font-weight:bold">FROM</span> student3  <span style="color:#000;font-weight:bold">LIMIT</span> <span style="color:#099">2</span>,<span style="color:#099">6</span>;

<span style="color:#000;font-weight:bold">#</span>limit语句的格式<span style="color:#a61717;background-color:#e3d2d2">：</span>  <span style="color:#000;font-weight:bold">limit</span> <span style="color:#a61717;background-color:#e3d2d2">开始索引值，条数</span>
</code></pre></td></tr></table>
</div>
</div><p>##子查询</p>
<div class="highlight"><div style="background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4">
<table style="border-spacing:0;padding:0;margin:0;border:0;width:auto;overflow:auto;display:block;"><tr><td style="vertical-align:top;padding:0;margin:0;border:0;">
<pre style="background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"> 1
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"> 2
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"> 3
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"> 4
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"> 5
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"> 6
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"> 7
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"> 8
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"> 9
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">10
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">11
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">12
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">13
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">14
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">15
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">16
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">17
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">18
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">19
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">20
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">21
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">22
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">23
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">24
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">25
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">26
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">27
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">28
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">29
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">30
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">31
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">32
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">33
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">34
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">35
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">36
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">37
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">38
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">39
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">40
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">41
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">42
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">43
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">44
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">45
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">46
</span></code></pre></td>
<td style="vertical-align:top;padding:0;margin:0;border:0;;width:100%">
<pre style="background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-sql" data-lang="sql"><span style="color:#000;font-weight:bold">#</span><span style="color:#a61717;background-color:#e3d2d2">需求：</span> <span style="color:#a61717;background-color:#e3d2d2">查询所有员工的信息，并且显示出该员工所属的部门名称。</span> 

<span style="color:#000;font-weight:bold">SELECT</span> e.<span style="color:#000;font-weight:bold">*</span>,p.<span style="color:#000;font-weight:bold">`</span>dname<span style="color:#000;font-weight:bold">`</span> <span style="color:#000;font-weight:bold">FROM</span> emp e <span style="color:#000;font-weight:bold">LEFT</span> <span style="color:#000;font-weight:bold">JOIN</span> dept p <span style="color:#000;font-weight:bold">ON</span>  e.<span style="color:#000;font-weight:bold">`</span>dept_id<span style="color:#000;font-weight:bold">`=</span>p.<span style="color:#000;font-weight:bold">`</span>id<span style="color:#000;font-weight:bold">`</span>
<span style="color:#000;font-weight:bold">#</span><span style="color:#a61717;background-color:#e3d2d2">查询唐僧员工的信息以及所属的部门名称。</span>

<span style="color:#000;font-weight:bold">SELECT</span> e.<span style="color:#000;font-weight:bold">*</span>,p.<span style="color:#000;font-weight:bold">`</span>dname<span style="color:#000;font-weight:bold">`</span> <span style="color:#000;font-weight:bold">FROM</span> emp e <span style="color:#000;font-weight:bold">LEFT</span> <span style="color:#000;font-weight:bold">JOIN</span> dept p <span style="color:#000;font-weight:bold">ON</span>  e.<span style="color:#000;font-weight:bold">`</span>dept_id<span style="color:#000;font-weight:bold">`=</span>p.<span style="color:#000;font-weight:bold">`</span>id<span style="color:#000;font-weight:bold">`</span> <span style="color:#000;font-weight:bold">WHERE</span> ename<span style="color:#000;font-weight:bold">=</span><span style="color:#d14">&#39;唐僧&#39;</span>

<span style="color:#000;font-weight:bold">#</span><span style="color:#a61717;background-color:#e3d2d2">查询出来工资最高的员工信息。</span>
<span style="color:#000;font-weight:bold">SELECT</span> e.<span style="color:#000;font-weight:bold">*</span> <span style="color:#000;font-weight:bold">FROM</span> emp e  <span style="color:#000;font-weight:bold">WHERE</span> e.<span style="color:#000;font-weight:bold">`</span>salary<span style="color:#000;font-weight:bold">`=</span>(<span style="color:#000;font-weight:bold">SELECT</span> <span style="color:#000;font-weight:bold">MAX</span>(e.<span style="color:#000;font-weight:bold">`</span>salary<span style="color:#000;font-weight:bold">`</span>) <span style="color:#000;font-weight:bold">FROM</span> emp e)  
<span style="color:#000;font-weight:bold">#</span><span style="color:#a61717;background-color:#e3d2d2">第一步：</span> <span style="color:#a61717;background-color:#e3d2d2">查询出来当前最高的薪资</span>
<span style="color:#000;font-weight:bold">SELECT</span> <span style="color:#000;font-weight:bold">MAX</span>(e.<span style="color:#000;font-weight:bold">`</span>salary<span style="color:#000;font-weight:bold">`</span>) <span style="color:#000;font-weight:bold">FROM</span> emp e

<span style="color:#000;font-weight:bold">#</span><span style="color:#a61717;background-color:#e3d2d2">第二步：查询员工的薪资等于最高薪资的信息</span>




<span style="color:#000;font-weight:bold">#</span><span style="color:#099">2</span>.<span style="color:#a61717;background-color:#e3d2d2">查询工资小于平均工资的员工有哪些？</span>
<span style="color:#000;font-weight:bold">SELECT</span> e.<span style="color:#000;font-weight:bold">*</span> <span style="color:#000;font-weight:bold">FROM</span> emp e  <span style="color:#000;font-weight:bold">WHERE</span> e.<span style="color:#000;font-weight:bold">`</span>salary<span style="color:#000;font-weight:bold">`&lt;</span>(<span style="color:#000;font-weight:bold">SELECT</span> <span style="color:#000;font-weight:bold">AVG</span>(e.<span style="color:#000;font-weight:bold">`</span>salary<span style="color:#000;font-weight:bold">`</span>) <span style="color:#a61717;background-color:#e3d2d2">平均工资</span>  <span style="color:#000;font-weight:bold">FROM</span> emp e)
<span style="color:#000;font-weight:bold">#</span><span style="color:#a61717;background-color:#e3d2d2">第一步：查询出平均工资</span>

<span style="color:#000;font-weight:bold">#</span><span style="color:#a61717;background-color:#e3d2d2">查询工资低于平均工资的员工</span>


<span style="color:#000;font-weight:bold">#</span><span style="color:#099">1</span>.<span style="color:#a61717;background-color:#e3d2d2">查询工资大于</span><span style="color:#099">5000</span><span style="color:#a61717;background-color:#e3d2d2">的员工，来自于哪些部门的名字</span>

<span style="color:#000;font-weight:bold">#</span><span style="color:#a61717;background-color:#e3d2d2">第一步：</span> <span style="color:#a61717;background-color:#e3d2d2">查询出工资大于</span><span style="color:#099">5000</span><span style="color:#a61717;background-color:#e3d2d2">的员工的部门编号</span>

<span style="color:#000;font-weight:bold">SELECT</span> d.dname <span style="color:#000;font-weight:bold">FROM</span> dept d <span style="color:#000;font-weight:bold">WHERE</span>  id <span style="color:#000;font-weight:bold">IN</span>((<span style="color:#000;font-weight:bold">SELECT</span> e.<span style="color:#000;font-weight:bold">`</span>dept_id<span style="color:#000;font-weight:bold">`</span> <span style="color:#000;font-weight:bold">FROM</span> emp e  <span style="color:#000;font-weight:bold">WHERE</span> e.<span style="color:#000;font-weight:bold">`</span>salary<span style="color:#000;font-weight:bold">`&gt;</span><span style="color:#099">5000</span>))
<span style="color:#000;font-weight:bold">#</span><span style="color:#a61717;background-color:#e3d2d2">第二步；查出来部门的信息</span>


<span style="color:#000;font-weight:bold">#</span><span style="color:#099">2</span>.<span style="color:#a61717;background-color:#e3d2d2">查询教研部与学工部所有的员工信息</span>

<span style="color:#000;font-weight:bold">#</span><span style="color:#a61717;background-color:#e3d2d2">第一步：</span> <span style="color:#a61717;background-color:#e3d2d2">查询出开发部与财务部的</span>id号
<span style="color:#000;font-weight:bold">SELECT</span> e.<span style="color:#000;font-weight:bold">*</span> <span style="color:#000;font-weight:bold">FROM</span> emp e <span style="color:#000;font-weight:bold">WHERE</span> e.<span style="color:#000;font-weight:bold">`</span>dept_id<span style="color:#000;font-weight:bold">`</span> <span style="color:#000;font-weight:bold">IN</span>((<span style="color:#000;font-weight:bold">SELECT</span> d.id <span style="color:#000;font-weight:bold">FROM</span> dept  d <span style="color:#000;font-weight:bold">WHERE</span>  d.dname<span style="color:#000;font-weight:bold">=</span><span style="color:#d14">&#39;教研部&#39;</span> <span style="color:#000;font-weight:bold">OR</span> d.dname<span style="color:#000;font-weight:bold">=</span><span style="color:#d14">&#39;学工部&#39;</span> ))
<span style="color:#000;font-weight:bold">#</span><span style="color:#a61717;background-color:#e3d2d2">第二步：</span> <span style="color:#a61717;background-color:#e3d2d2">查询员工信息</span>



<span style="color:#000;font-weight:bold">#</span> <span style="color:#a61717;background-color:#e3d2d2">查询出</span><span style="color:#099">2011</span><span style="color:#a61717;background-color:#e3d2d2">年以后入职的员工信息，包括部门名称</span> 

<span style="color:#000;font-weight:bold">#</span><span style="color:#a61717;background-color:#e3d2d2">第一步：</span> <span style="color:#a61717;background-color:#e3d2d2">先找出</span><span style="color:#099">2001</span><span style="color:#a61717;background-color:#e3d2d2">年后入职的员工信息</span> 

<span style="color:#000;font-weight:bold">SELECT</span> e.<span style="color:#000;font-weight:bold">*</span> <span style="color:#000;font-weight:bold">FROM</span> emp e <span style="color:#000;font-weight:bold">WHERE</span> e.<span style="color:#000;font-weight:bold">`</span>joindate<span style="color:#000;font-weight:bold">`</span> <span style="color:#000;font-weight:bold">&gt;</span> <span style="color:#d14">&#39;2001-01-01&#39;</span>
<span style="color:#000;font-weight:bold">#</span><span style="color:#a61717;background-color:#e3d2d2">第二步：</span> <span style="color:#a61717;background-color:#e3d2d2">查询出员工的信息以及部门的信息</span>
</code></pre></td></tr></table>
</div>
</div><h2 id="多表查询">多表查询</h2>
<div class="highlight"><div style="background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4">
<table style="border-spacing:0;padding:0;margin:0;border:0;width:auto;overflow:auto;display:block;"><tr><td style="vertical-align:top;padding:0;margin:0;border:0;">
<pre style="background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"> 1
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"> 2
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"> 3
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"> 4
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"> 5
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"> 6
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"> 7
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"> 8
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"> 9
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">10
</span></code></pre></td>
<td style="vertical-align:top;padding:0;margin:0;border:0;;width:100%">
<pre style="background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-sql" data-lang="sql"><span style="color:#000;font-weight:bold">#</span><span style="color:#a61717;background-color:#e3d2d2">查询所有员工信息。显示员工编号，员工姓名，工资，职务名称，职务描述</span>
<span style="color:#000;font-weight:bold">SELECT</span> e.id,e.ename,e.salary,j.<span style="color:#000;font-weight:bold">`</span>jname<span style="color:#000;font-weight:bold">`</span>,j.<span style="color:#000;font-weight:bold">`</span>description<span style="color:#000;font-weight:bold">`</span> <span style="color:#000;font-weight:bold">FROM</span> emp e <span style="color:#000;font-weight:bold">LEFT</span> <span style="color:#000;font-weight:bold">JOIN</span> job j <span style="color:#000;font-weight:bold">ON</span> e.<span style="color:#000;font-weight:bold">`</span>job_id<span style="color:#000;font-weight:bold">`=</span>j.<span style="color:#000;font-weight:bold">`</span>id<span style="color:#000;font-weight:bold">`</span>

<span style="color:#000;font-weight:bold">#</span><span style="color:#a61717;background-color:#e3d2d2">查询所有员工信息。显示员工编号，员工姓名，工资，职务名称，职务描述，部门名称，部门位置</span>
 <span style="color:#000;font-weight:bold">SELECT</span> e.id,e.ename,e.salary,j.<span style="color:#000;font-weight:bold">`</span>jname<span style="color:#000;font-weight:bold">`</span>,j.<span style="color:#000;font-weight:bold">`</span>description<span style="color:#000;font-weight:bold">`</span>,d.dname,d.loc <span style="color:#000;font-weight:bold">FROM</span> emp e <span style="color:#000;font-weight:bold">LEFT</span> <span style="color:#000;font-weight:bold">JOIN</span> job j <span style="color:#000;font-weight:bold">ON</span> e.<span style="color:#000;font-weight:bold">`</span>job_id<span style="color:#000;font-weight:bold">`=</span>j.<span style="color:#000;font-weight:bold">`</span>id<span style="color:#000;font-weight:bold">`</span> <span style="color:#000;font-weight:bold">LEFT</span> <span style="color:#000;font-weight:bold">JOIN</span> dept d <span style="color:#000;font-weight:bold">ON</span> e.<span style="color:#000;font-weight:bold">`</span>dept_id<span style="color:#000;font-weight:bold">`=</span>d.id

<span style="color:#000;font-weight:bold">#</span><span style="color:#a61717;background-color:#e3d2d2">查询所有员工信息。显示员工姓名，工资，职务名称，职务描述，部门名称，部门位置，工资等级</span>


<span style="color:#000;font-weight:bold">SELECT</span>  e.<span style="color:#000;font-weight:bold">`</span>id<span style="color:#000;font-weight:bold">`</span>,e.<span style="color:#000;font-weight:bold">`</span>ename<span style="color:#000;font-weight:bold">`</span>,e.<span style="color:#000;font-weight:bold">`</span>salary<span style="color:#000;font-weight:bold">`</span> , j.<span style="color:#000;font-weight:bold">`</span>jname<span style="color:#000;font-weight:bold">`</span>, j.<span style="color:#000;font-weight:bold">`</span>description<span style="color:#000;font-weight:bold">`</span>, d.<span style="color:#000;font-weight:bold">`</span>dname<span style="color:#000;font-weight:bold">`</span>,d.<span style="color:#000;font-weight:bold">`</span>loc<span style="color:#000;font-weight:bold">`</span>, s.<span style="color:#000;font-weight:bold">`</span>grade<span style="color:#000;font-weight:bold">`</span> <span style="color:#000;font-weight:bold">FROM</span>  emp e, job j , dept d, salarygrade s <span style="color:#000;font-weight:bold">WHERE</span> e.<span style="color:#000;font-weight:bold">`</span>job_id<span style="color:#000;font-weight:bold">`=</span>j.<span style="color:#000;font-weight:bold">`</span>id<span style="color:#000;font-weight:bold">`</span> <span style="color:#000;font-weight:bold">AND</span> e.<span style="color:#000;font-weight:bold">`</span>dept_id<span style="color:#000;font-weight:bold">`=</span>d.<span style="color:#000;font-weight:bold">`</span>id<span style="color:#000;font-weight:bold">`</span> <span style="color:#000;font-weight:bold">AND</span> e.<span style="color:#000;font-weight:bold">`</span>salary<span style="color:#000;font-weight:bold">`</span> <span style="color:#000;font-weight:bold">BETWEEN</span> s.<span style="color:#000;font-weight:bold">`</span>losalary<span style="color:#000;font-weight:bold">`</span> <span style="color:#000;font-weight:bold">AND</span> s.<span style="color:#000;font-weight:bold">`</span>hisalary<span style="color:#000;font-weight:bold">`</span> ;
</code></pre></td></tr></table>
</div>
</div>
        </div>

        
<div class="post-archive">
    <ul class="post-copyright">
        <li><strong>原文作者：</strong><a rel="author" href="https://laoer123.gitee.io/laoer123">Jeremy Sze</a></li>
        <li style="word-break:break-all"><strong>原文链接：</strong><a href="https://laoer123.gitee.io/laoer123/post/mysql%E6%80%BB%E7%BB%93/">https://laoer123.gitee.io/laoer123/post/mysql%E6%80%BB%E7%BB%93/</a></li>
        <li><strong>版权声明：</strong>本作品采用<a rel="license" href="https://creativecommons.org/licenses/by-nc-nd/4.0/">知识共享署名-非商业性使用-禁止演绎 4.0 国际许可协议</a>进行许可，非商业转载请注明出处（作者，原文链接），商业转载请联系作者获得授权。</li>
    </ul>
</div>
<br/>



        

<div class="post-archive">
    <h2>See Also</h2>
    <ul class="listing">
        
        <li><a href="/laoer123/post/git%E6%80%BB%E7%BB%93/">git总结</a></li>
        
        <li><a href="/laoer123/post/java%E4%B8%89%E5%A4%A7%E7%89%B9%E6%80%A7/">java三大特性_封装继承多态</a></li>
        
        <li><a href="/laoer123/post/%E9%9D%A2%E5%90%91%E8%BF%87%E7%A8%8B%E4%B8%8E%E9%9D%A2%E5%90%91%E5%AF%B9%E8%B1%A1%E7%9A%84%E5%8C%BA%E5%88%AB/">面向过程与面向对象的区别</a></li>
        
        <li><a href="/laoer123/archives/">归档</a></li>
        
        <li><a href="/laoer123/search/">搜索</a></li>
        
    </ul>
</div>


        <div class="post-meta meta-tags">
            
            <ul class="clearfix">
                
                <li><a href='https://laoer123.gitee.io/tags/mysql'>mysql</a></li>
                
            </ul>
            
        </div>
    </article>
    
    <div id="disqus_thread"></div>
<script type="application/javascript">
    var disqus_config = function () {
    
    
    
    };
    (function() {
        if (["localhost", "127.0.0.1"].indexOf(window.location.hostname) != -1) {
            document.getElementById('disqus_thread').innerHTML = 'Disqus comments not available by default when the website is previewed locally.';
            return;
        }
        var d = document, s = d.createElement('script'); s.async = true;
        s.src = '//' + "yourdiscussshortname" + '.disqus.com/embed.js';
        s.setAttribute('data-timestamp', +new Date());
        (d.head || d.body).appendChild(s);
    })();
</script>
<noscript>Please enable JavaScript to view the <a href="https://disqus.com/?ref_noscript">comments powered by Disqus.</a></noscript>
<a href="https://disqus.com" class="dsq-brlink">comments powered by <span class="logo-disqus">Disqus</span></a>

    
    
</div>

                </div>

                <div id="secondary">
    <section class="widget">
        <form id="search" action='https://laoer123.gitee.io/laoer123/search/' method="get" accept-charset="utf-8" target="_blank" _lpchecked="1">
      
      <input type="text" name="q" maxlength="20" placeholder="Search">
      <input type="hidden" name="sitesearch" value="https://laoer123.gitee.io/laoer123">
      <button type="submit" class="submit icon-search"></button>
</form>
    </section>
    
    <section class="widget">
        <h3 class="widget-title">最近文章</h3>
<ul class="widget-list">
    
    <li>
        <a href="https://laoer123.gitee.io/laoer123/post/springcloud%E4%B8%8EspringcloudAlibaba%E6%80%BB%E7%BB%93/" title="springcloud与springcloudAlibaba总结">springcloud与springcloudAlibaba总结</a>
    </li>
    
    <li>
        <a href="https://laoer123.gitee.io/laoer123/post/Seata%E6%80%BB%E7%BB%93/" title="Seata总结">Seata总结</a>
    </li>
    
    <li>
        <a href="https://laoer123.gitee.io/laoer123/post/OpenFegin%E6%80%BB%E7%BB%93/" title="OpenFegin总结">OpenFegin总结</a>
    </li>
    
    <li>
        <a href="https://laoer123.gitee.io/laoer123/post/SpringCloudGateWay%E6%80%BB%E7%BB%93/" title="SpringCloudGateWay总结">SpringCloudGateWay总结</a>
    </li>
    
    <li>
        <a href="https://laoer123.gitee.io/laoer123/post/SpringCloudRibbon/" title="SpringCloudRibbon总结">SpringCloudRibbon总结</a>
    </li>
    
    <li>
        <a href="https://laoer123.gitee.io/laoer123/post/Nacos%E9%85%8D%E7%BD%AE%E6%B3%A8%E5%86%8C%E4%B8%8E%E5%8F%91%E7%8E%B0/" title="Nacos配置注册与发现">Nacos配置注册与发现</a>
    </li>
    
    <li>
        <a href="https://laoer123.gitee.io/laoer123/post/Nacos%E9%85%8D%E7%BD%AE%E7%AE%A1%E7%90%86%E6%BC%94%E7%A4%BA/" title="Nacos配置管理演示">Nacos配置管理演示</a>
    </li>
    
    <li>
        <a href="https://laoer123.gitee.io/laoer123/post/Nacos%E6%80%BB%E7%BB%93/" title="什么是Nacos">什么是Nacos</a>
    </li>
    
    <li>
        <a href="https://laoer123.gitee.io/laoer123/post/Sentinel%E6%96%B0%E6%89%8B%E6%8C%87%E5%8D%97/" title="Sentinel新手指南">Sentinel新手指南</a>
    </li>
    
    <li>
        <a href="https://laoer123.gitee.io/laoer123/post/Sentinel%E6%8E%A7%E5%88%B6%E5%8F%B0/" title="Sentinel控制台">Sentinel控制台</a>
    </li>
    
</ul>
    </section>

    

    <section class="widget">
        <h3 class="widget-title">分类</h3>
<ul class="widget-list">
    
    <li><a href="https://laoer123.gitee.io/laoer123/categories/Linux/">Linux (2)</a></li>
    
    <li><a href="https://laoer123.gitee.io/laoer123/categories/NoSql%E6%95%B0%E6%8D%AE%E5%BA%93/">NoSql数据库 (1)</a></li>
    
    <li><a href="https://laoer123.gitee.io/laoer123/categories/SpringCloud/">SpringCloud (2)</a></li>
    
    <li><a href="https://laoer123.gitee.io/laoer123/categories/SpringCloudAlibaba/">SpringCloudAlibaba (11)</a></li>
    
    <li><a href="https://laoer123.gitee.io/laoer123/categories/SpringCloudAlibabaSpringCloud/">SpringCloudAlibaba,SpringCloud (1)</a></li>
    
    <li><a href="https://laoer123.gitee.io/laoer123/categories/docker/">docker (2)</a></li>
    
    <li><a href="https://laoer123.gitee.io/laoer123/categories/java%E5%9F%BA%E7%A1%80/">java基础 (10)</a></li>
    
    <li><a href="https://laoer123.gitee.io/laoer123/categories/spring/">spring (4)</a></li>
    
    <li><a href="https://laoer123.gitee.io/laoer123/categories/%E4%BA%8B%E5%8A%A1/">事务 (1)</a></li>
    
    <li><a href="https://laoer123.gitee.io/laoer123/categories/%E5%88%86%E5%B8%83%E5%BC%8F/">分布式 (1)</a></li>
    
    <li><a href="https://laoer123.gitee.io/laoer123/categories/%E5%89%8D%E7%AB%AF%E5%BE%AE%E6%9C%8D%E5%8A%A1/">前端微服务 (1)</a></li>
    
    <li><a href="https://laoer123.gitee.io/laoer123/categories/%E5%89%8D%E7%AB%AF%E6%A1%86%E6%9E%B6/">前端框架 (2)</a></li>
    
    <li><a href="https://laoer123.gitee.io/laoer123/categories/%E6%8C%81%E7%BB%AD%E9%9B%86%E6%88%90/">持续集成 (1)</a></li>
    
    <li><a href="https://laoer123.gitee.io/laoer123/categories/%E6%90%9C%E7%B4%A2%E5%BC%95%E6%93%8E/">搜索引擎 (1)</a></li>
    
    <li><a href="https://laoer123.gitee.io/laoer123/categories/%E6%95%B0%E6%8D%AE%E5%B1%82%E6%A1%86%E6%9E%B6/">数据层框架 (1)</a></li>
    
    <li><a href="https://laoer123.gitee.io/laoer123/categories/%E6%95%B0%E6%8D%AE%E5%BA%93/">数据库 (5)</a></li>
    
    <li><a href="https://laoer123.gitee.io/laoer123/categories/%E6%9C%8D%E5%8A%A1%E5%99%A8/">服务器 (1)</a></li>
    
    <li><a href="https://laoer123.gitee.io/laoer123/categories/%E6%9E%B6%E6%9E%84/">架构 (1)</a></li>
    
    <li><a href="https://laoer123.gitee.io/laoer123/categories/%E6%B6%88%E6%81%AF%E4%B8%AD%E9%97%B4%E4%BB%B6/">消息中间件 (1)</a></li>
    
    <li><a href="https://laoer123.gitee.io/laoer123/categories/%E7%89%88%E6%9C%AC%E6%8E%A7%E5%88%B6/">版本控制 (1)</a></li>
    
    <li><a href="https://laoer123.gitee.io/laoer123/categories/%E7%BC%93%E5%AD%98/">缓存 (1)</a></li>
    
    <li><a href="https://laoer123.gitee.io/laoer123/categories/%E8%AE%A4%E8%AF%81/">认证 (2)</a></li>
    
    <li><a href="https://laoer123.gitee.io/laoer123/categories/%E8%BF%90%E7%BB%B4/">运维 (1)</a></li>
    
    <li><a href="https://laoer123.gitee.io/laoer123/categories/%E9%83%A8%E7%BD%B2/">部署 (1)</a></li>
    
</ul>
    </section>

    <section class="widget">
        <h3 class="widget-title">标签</h3>
<div class="tagcloud">
    
    <a href="https://laoer123.gitee.io/laoer123/tags/Dubbo/">Dubbo</a>
    
    <a href="https://laoer123.gitee.io/laoer123/tags/ES6/">ES6</a>
    
    <a href="https://laoer123.gitee.io/laoer123/tags/ElasticSearch/">ElasticSearch</a>
    
    <a href="https://laoer123.gitee.io/laoer123/tags/ElementUI/">ElementUI</a>
    
    <a href="https://laoer123.gitee.io/laoer123/tags/Eureka/">Eureka</a>
    
    <a href="https://laoer123.gitee.io/laoer123/tags/Feign/">Feign</a>
    
    <a href="https://laoer123.gitee.io/laoer123/tags/JDBCTemplate/">JDBCTemplate</a>
    
    <a href="https://laoer123.gitee.io/laoer123/tags/JPA/">JPA</a>
    
    <a href="https://laoer123.gitee.io/laoer123/tags/JWT/">JWT</a>
    
    <a href="https://laoer123.gitee.io/laoer123/tags/Jenkins/">Jenkins</a>
    
    <a href="https://laoer123.gitee.io/laoer123/tags/Linux%E5%9F%BA%E7%A1%80/">Linux基础</a>
    
    <a href="https://laoer123.gitee.io/laoer123/tags/Linux%E9%85%8D%E7%BD%AE%E8%81%94%E7%BD%91/">Linux配置联网</a>
    
    <a href="https://laoer123.gitee.io/laoer123/tags/MongoDB/">MongoDB</a>
    
    <a href="https://laoer123.gitee.io/laoer123/tags/Nacos/">Nacos</a>
    
    <a href="https://laoer123.gitee.io/laoer123/tags/ORACLE/">ORACLE</a>
    
    <a href="https://laoer123.gitee.io/laoer123/tags/OpenFegin/">OpenFegin</a>
    
    <a href="https://laoer123.gitee.io/laoer123/tags/RabbitMQ/">RabbitMQ</a>
    
    <a href="https://laoer123.gitee.io/laoer123/tags/Seata/">Seata</a>
    
    <a href="https://laoer123.gitee.io/laoer123/tags/Sentinel/">Sentinel</a>
    
    <a href="https://laoer123.gitee.io/laoer123/tags/SpringCloudGateWay/">SpringCloudGateWay</a>
    
    <a href="https://laoer123.gitee.io/laoer123/tags/SpringCloudRibbon/">SpringCloudRibbon</a>
    
    <a href="https://laoer123.gitee.io/laoer123/tags/SpringCloudSpringCloudAlibaba/">SpringCloud,SpringCloudAlibaba</a>
    
    <a href="https://laoer123.gitee.io/laoer123/tags/VUE/">VUE</a>
    
    <a href="https://laoer123.gitee.io/laoer123/tags/docker/">docker</a>
    
    <a href="https://laoer123.gitee.io/laoer123/tags/git/">git</a>
    
    <a href="https://laoer123.gitee.io/laoer123/tags/gogs/">gogs</a>
    
    <a href="https://laoer123.gitee.io/laoer123/tags/hystrix/">hystrix</a>
    
    <a href="https://laoer123.gitee.io/laoer123/tags/mysql/">mysql</a>
    
    <a href="https://laoer123.gitee.io/laoer123/tags/nginx/">nginx</a>
    
    <a href="https://laoer123.gitee.io/laoer123/tags/nodeJS/">nodeJS</a>
    
    <a href="https://laoer123.gitee.io/laoer123/tags/npm/">npm</a>
    
    <a href="https://laoer123.gitee.io/laoer123/tags/springCache/">springCache</a>
    
    <a href="https://laoer123.gitee.io/laoer123/tags/springDataJPA/">springDataJPA</a>
    
    <a href="https://laoer123.gitee.io/laoer123/tags/springboot/">springboot</a>
    
    <a href="https://laoer123.gitee.io/laoer123/tags/springcloudbus/">springcloudbus</a>
    
    <a href="https://laoer123.gitee.io/laoer123/tags/springcloudconfig/">springcloudconfig</a>
    
    <a href="https://laoer123.gitee.io/laoer123/tags/springdataredis/">springdataredis</a>
    
    <a href="https://laoer123.gitee.io/laoer123/tags/zuul/">zuul</a>
    
    <a href="https://laoer123.gitee.io/laoer123/tags/%E5%88%86%E5%B8%83%E5%BC%8F/">分布式</a>
    
    <a href="https://laoer123.gitee.io/laoer123/tags/%E5%88%86%E5%B8%83%E5%BC%8F%E4%BA%8B%E5%8A%A1/">分布式事务</a>
    
    <a href="https://laoer123.gitee.io/laoer123/tags/%E5%88%9B%E5%BB%BA%E6%A8%A1%E5%BC%8F/">创建模式</a>
    
    <a href="https://laoer123.gitee.io/laoer123/tags/%E5%BE%AE%E6%9C%8D%E5%8A%A1/">微服务</a>
    
    <a href="https://laoer123.gitee.io/laoer123/tags/%E6%8E%92%E5%BA%8F/">排序</a>
    
    <a href="https://laoer123.gitee.io/laoer123/tags/%E6%9C%8D%E5%8A%A1%E9%95%9C%E5%83%8F%E7%9A%84%E6%9E%84%E5%BB%BA%E4%B8%8E%E9%83%A8%E7%BD%B2/">服务镜像的构建与部署</a>
    
    <a href="https://laoer123.gitee.io/laoer123/tags/%E7%BB%93%E6%9E%84%E6%A8%A1%E5%BC%8F/">结构模式</a>
    
    <a href="https://laoer123.gitee.io/laoer123/tags/%E8%A1%8C%E4%B8%BA%E6%A8%A1%E5%BC%8F/">行为模式</a>
    
    <a href="https://laoer123.gitee.io/laoer123/tags/%E8%AE%BE%E8%AE%A1%E6%A8%A1%E5%BC%8F/">设计模式</a>
    
    <a href="https://laoer123.gitee.io/laoer123/tags/%E8%BF%90%E7%BB%B4/">运维</a>
    
</div>
    </section>

    
<section class="widget">
    <h3 class="widget-title">友情链接</h3>
    <ul class="widget-list">
        
        <li>
            <a target="_blank" href="https://www.cnblogs.com/Jeremy95-Sze/" title="Jeremy Sze的博客">Jeremy Sze的博客</a>
        </li>
        
        <li>
            <a target="_blank" href="https://github.com/Jeremy95-Sze" title="Jeremy Sze的github">Jeremy Sze的github</a>
        </li>
        
    </ul>
</section>


    <section class="widget">
        <h3 class="widget-title">其它</h3>
        <ul class="widget-list">
            <li><a href="https://laoer123.gitee.io/laoer123/index.xml">文章 RSS</a></li>
        </ul>
    </section>
</div>
            </div>
        </div>
    </div>
    <footer id="footer">
    <div class="container">
        &copy; 2023 <a href="https://laoer123.gitee.io/laoer123">Jeremy Sze的博客 By Jeremy Sze</a>.
        Powered by <a rel="nofollow noreferer noopener" href="https://gohugo.io" target="_blank">Hugo</a>.
        <a href="https://www.flysnow.org/" target="_blank">Theme</a> based on <a href="https://github.com/flysnow-org/maupassant-hugo" target="_blank">maupassant</a>.
        
    </div>
</footer>


    
    <script src="//cdnjs.cloudflare.com/ajax/libs/webfont/1.6.28/webfontloader.js" crossorigin="anonymous"></script>
        <script src="//cdnjs.cloudflare.com/ajax/libs/snap.svg/0.5.1/snap.svg-min.js" crossorigin="anonymous"></script>
        <script src="//cdnjs.cloudflare.com/ajax/libs/underscore.js/1.9.1/underscore-min.js" crossorigin="anonymous"></script>
        <script src="//cdnjs.cloudflare.com/ajax/libs/js-sequence-diagrams/1.0.6/sequence-diagram-min.js" crossorigin="anonymous"></script>
        <script>(function () {
            if (!window.Diagram) return;
            const blocks = document.querySelectorAll('pre code.language-sequence');
            for (let i = 0; i < blocks.length; i++) {
                const block = blocks[i];
                
                const rootElement = block.parentNode;
                const container = document.createElement('div');
                const id = `js-sequence-diag-${i}`;
                container.id = id;
                container.className = 'align-center';
                container.setAttribute("style", "overFlow-x:auto");
                rootElement.parentNode.replaceChild(container, rootElement);

                const diagram = Diagram.parse(block.childNodes[0].nodeValue);
                diagram.drawSVG(id, window.sequenceDiagramsOptions
                    ? window.sequenceDiagramsOptions
                    : { theme: 'simple' });
            }
        })();
        </script><script type="text/javascript">
        window.MathJax = {
            tex2jax: {
                inlineMath: [['$', '$']],
                processEscapes: true
                }
            };
    </script>
    <script src='https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js?config=TeX-MML-AM_CHTML' async></script>


<a id="rocket" href="#top"></a>
<script type="text/javascript" src='/laoer123/js/totop.js?v=0.0.0' async=""></script>

<script type="application/javascript">
var doNotTrack = false;
if (!doNotTrack) {
	window.ga=window.ga||function(){(ga.q=ga.q||[]).push(arguments)};ga.l=+new Date;
	ga('create', 'GA ID', 'auto');
	
	ga('send', 'pageview');
}
</script>
<script async src='https://www.google-analytics.com/analytics.js'></script>



    <script type="text/javascript" src="//busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js" async></script>




    <script src='/laoer123/js/douban.js'></script>

</body>

</html>